home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HTBasic 9.3
/
HTBasic 9.3.iso
/
83win
/
data1.cab
/
Basic_Plus_Examples
/
RADIOBTN
< prev
next >
Wrap
Text File
|
2001-03-02
|
8KB
|
241 lines
10 ! ******************************************************************
20 ! Example: RADIOBUTTON Widget
30 !
40 ! This program generates a panel with two tab groups of RADIOBUTTON
50 ! widgets. You can set buttons and observe their behavior. A
60 ! PRINTER widget is used to display the state of the buttons used.
70 !
80 ! ******************************************************************
90 !
100 ! Define colors
110 !
120 INTEGER Black,White,Red,Yellow,Green,Cyan,Blue,Magenta
130 DATA 0,1,2,3,4,5,6,7
140 READ Black,White,Red,Yellow,Green,Cyan,Blue,Magenta
150 !
160 ! Set the PRINTER widget handle COMmon
170 !
180 COM @Printer
190 !
200 ! Variables for display and widget handling
210 !
220 INTEGER Nlines,D(1:4) ! Used for display setup
230 REAL Dw,Dh ! Display dimensions
240 REAL Px,Py,Pw,Ph,Iw,Ih ! Main PANEL parameters
250 REAL Gaph,Gapw,Bh,Bw,Sh,Sw,Prh,Prw! Widget dimensions
260 REAL R1,R2,R3,R4,R5,C1,C2,C3,C4,C5! Widget coordinates
270 !
280 ! Set up display
290 !
300 STATUS CRT,13;Nlines
310 GESCAPE CRT,3;D(*)
320 Dw=D(3)-D(1)
330 Dh=(D(4)-D(2))*((Nlines-7)/Nlines)
340 !
350 ! Set up PANEL coordinates
360 !
370 Pw=Dw*.5
380 Ph=Dh*.65
390 Px=(Dw-Pw)
400 Py=(Dh-Ph)
410 !
420 ! Build PANEL widget and add SYSTEM MENU to PANEL
430 !
440 CLEAR SCREEN
450 ASSIGN @Main TO WIDGET "PANEL";SET ("VISIBLE":0)
460 CONTROL @Main;SET ("RESIZABLE":0,"MAXIMIZABLE":0)
470 CONTROL @Main;SET ("X":Px/4,"Y":Py/2,"WIDTH":1.3*Pw,"HEIGHT":1.5*Ph)
480 CONTROL @Main;SET ("TITLE":" Example: RADIOBUTTON Widget")
490 CONTROL @Main;SET ("SYSTEM MENU":"Quit")
500 !
510 ! Get interior dimensions
520 !
530 STATUS @Main;RETURN ("INSIDE WIDTH":Iw,"INSIDE HEIGHT":Ih)
540 !
550 ! Set up widget coordinates and dimensions
560 !
570 Gaph=Ih*.03 ! Vertical gap
580 Gapw=Iw*.03 ! Horizontal gap
590 Bh=Ih*.15 ! Button height
600 Bw=(Iw-Gapw*6)/5 ! Button width
610 Sh=Gaph ! Separator height
620 Prh=Ih-((Bh+Sh)*2+Gaph*6)! Printer height
630 Prw=(Iw-2*Gapw) ! Printer width
640 Sw=Prw ! Separator width
650 !
660 R1=Gaph ! Top row
670 R2=R1+Bh+Gaph! Row 2 = row 1 + button height + gap
680 R3=R2+Sh+Gaph! Row 3 = row 2 + button height + gap
690 R4=R3+Bh+Gaph! Row 4 = row 3 + button height + gap
700 R5=R4+Sh+Gaph! Row 5 = row 4 + button height + gap
710 !
720 C1=Gapw ! Left column
730 C2=C1+Bw+Gapw! Col 2 = col 1 + button width + gap
740 C3=C2+Bw+Gapw! Col 3 = col 2 + button width + gap
750 C4=C3+Bw+Gapw! Col 4 = col 3 + button width + gap
760 C5=C4+Bw+Gapw! Col 5 = col 4 + button width + gap
770 Pw=C5+Bw+Gapw! Panel width = col 5 + button width + gap
780 !
790 ! Set up first tab group of RADIOBUTTONs. Set tab stop on A1.
800 !
810 ASSIGN @A1 TO WIDGET "RADIOBUTTON";PARENT @Main
820 CONTROL @A1;SET ("LABEL":"A1","TAB STOP":1)
830 CONTROL @A1;SET ("X":C1,"Y":R1,"WIDTH":Bw,"HEIGHT":Bh)
840 !
850 ! No tab stop on A2
860 !
870 ASSIGN @A2 TO WIDGET "RADIOBUTTON";PARENT @Main
880 CONTROL @A2;SET ("LABEL":"A2","TAB STOP":0)
890 CONTROL @A2;SET ("X":C2,"Y":R1,"WIDTH":Bw,"HEIGHT":Bh)
900 !
910 ! No tab stop on A3
920 !
930 ASSIGN @A3 TO WIDGET "RADIOBUTTON";PARENT @Main
940 CONTROL @A3;SET ("LABEL":"A3","TAB STOP":0)
950 CONTROL @A3;SET ("X":C3,"Y":R1,"WIDTH":Bw,"HEIGHT":Bh)
960 !
970 ! No tab stop on A4
980 !
990 ASSIGN @A4 TO WIDGET "RADIOBUTTON";PARENT @Main
1000 CONTROL @A4;SET ("LABEL":"A4","TAB STOP":0)
1010 CONTROL @A4;SET ("X":C4,"Y":R1,"WIDTH":Bw,"HEIGHT":Bh)
1020 !
1030 ! No tab stop on A5
1040 !
1050 ASSIGN @A5 TO WIDGET "RADIOBUTTON";PARENT @Main
1060 CONTROL @A5;SET ("LABEL":"A5","TAB STOP":0)
1070 CONTROL @A5;SET ("X":C5,"Y":R1,"WIDTH":Bw,"HEIGHT":Bh)
1080 !
1090 ! Separator to mark off first tab group
1100 !
1110 ASSIGN @Sep1 TO WIDGET "SEPARATOR";PARENT @Main
1120 CONTROL @Sep1;SET ("X":C1,"Y":R2,"WIDTH":Sw,"HEIGHT":Sh)
1130 !
1140 ! Set up second tab group, set TAB STOP on B1
1150 !
1160 ASSIGN @B1 TO WIDGET "RADIOBUTTON";PARENT @Main
1170 CONTROL @B1;SET ("LABEL":"B1","TAB STOP":1)
1180 CONTROL @B1;SET ("X":C1,"Y":R3,"WIDTH":Bw,"HEIGHT":Bh)
1190 !
1200 ! B2, no tab stop
1210 !
1220 ASSIGN @B2 TO WIDGET "RADIOBUTTON";PARENT @Main
1230 CONTROL @B2;SET ("LABEL":"B2","TAB STOP":0)
1240 CONTROL @B2;SET ("X":C2,"Y":R3,"WIDTH":Bw,"HEIGHT":Bh)
1250 !
1260 ! B3, no tab stop
1270 !
1280 ASSIGN @B3 TO WIDGET "RADIOBUTTON";PARENT @Main
1290 CONTROL @B3;SET ("LABEL":"B3","TAB STOP":0)
1300 CONTROL @B3;SET ("X":C3,"Y":R3,"WIDTH":Bw,"HEIGHT":Bh)
1310 !
1320 ! B4, no tab stop
1330 !
1340 ASSIGN @B4 TO WIDGET "RADIOBUTTON";PARENT @Main
1350 CONTROL @B4;SET ("LABEL":"B4","TAB STOP":0)
1360 CONTROL @B4;SET ("X":C4,"Y":R3,"WIDTH":Bw,"HEIGHT":Bh)
1370 !
1380 ! B5, no tab stop
1390 !
1400 ASSIGN @B5 TO WIDGET "RADIOBUTTON";PARENT @Main
1410 CONTROL @B5;SET ("LABEL":"B5","TAB STOP":0)
1420 CONTROL @B5;SET ("X":C5,"Y":R3,"WIDTH":Bw,"HEIGHT":Bh)
1430 !
1440 ! Separator for second tab group
1450 !
1460 ASSIGN @Sep2 TO WIDGET "SEPARATOR";PARENT @Main
1470 CONTROL @Sep2;SET ("X":C1,"Y":R4,"WIDTH":Sw,"HEIGHT":Sh)
1480 !
1490 ! PRINTER widget
1500 !
1510 ASSIGN @Printer TO WIDGET "PRINTER";PARENT @Main,SET ("TAB STOP":1)
1520 CONTROL @Printer;SET ("TAB STOP":1)
1530 CONTROL @Printer;SET ("BACKGROUND":White)
1540 CONTROL @Printer;SET ("PEN":Black)
1550 CONTROL @Printer;SET ("X":C1,"Y":R5,"WIDTH":Prw,"HEIGHT":Prh)
1560 !
1570 ! Set up events
1580 !
1590 ON EVENT @A1,"CHANGED" GOSUB A1
1600 ON EVENT @A2,"CHANGED" GOSUB A2
1610 ON EVENT @A3,"CHANGED" GOSUB A3
1620 ON EVENT @A4,"CHANGED" GOSUB A4
1630 ON EVENT @A5,"CHANGED" GOSUB A5
1640 !
1650 ON EVENT @B1,"CHANGED" GOSUB B1
1660 ON EVENT @B2,"CHANGED" GOSUB B2
1670 ON EVENT @B3,"CHANGED" GOSUB B3
1680 ON EVENT @B4,"CHANGED" GOSUB B4
1690 ON EVENT @B5,"CHANGED" GOSUB B5
1700 !
1710 ON EVENT @Main,"SYSTEM MENU" GOTO Finis
1720 !
1730 ! Turn on panel
1740 !
1750 CONTROL @Main;SET ("VISIBLE":1)
1760 !
1770 ! Main loop, wait for event
1780 !
1790 LOOP
1800 WAIT FOR EVENT
1810 END LOOP
1820 STOP
1830 !
1840 ! Handlers for buttons
1850 !
1860 A1:!
1870 Show_value(@A1,"Button A1, VALUE:")
1880 RETURN
1890 !
1900 A2:!
1910 Show_value(@A2,"Button A2, VALUE:")
1920 RETURN
1930 !
1940 A3:!
1950 Show_value(@A3,"Button A3, VALUE:")
1960 RETURN
1970 !
1980 A4:!
1990 Show_value(@A4,"Button A4, VALUE:")
2000 RETURN
2010 !
2020 A5:!
2030 Show_value(@A5,"Button A5, VALUE:")
2040 RETURN
2050 !
2060 B1:!
2070 Show_value(@B1,"Button B1, VALUE:")
2080 RETURN
2090 !
2100 B2:!
2110 Show_value(@B2,"Button B2, VALUE:")
2120 RETURN
2130 !
2140 B3:!
2150 Show_value(@B3,"Button B3, VALUE:")
2160 RETURN
2170 !
2180 B4:!
2190 Show_value(@B4,"Button B4, VALUE:")
2200 RETURN
2210 !
2220 B5:!
2230 Show_value(@B5,"Button B5, VALUE:")
2240 RETURN
2250 !
2260 Finis:!
2270 ASSIGN @Main TO *! Delete PANEL widget
2280 END
2290 !
2300 ! ********** End of Main Program ****************
2310 !
2320 ! SUB to handle display of button inputs
2330 ! on PRINTER widget
2340 !
2350 SUB Show_value(@B,Text$)
2360 COM @Printer
2370 INTEGER Checked
2380 STATUS @B;RETURN ("VALUE":Checked)
2390 CONTROL @Printer;SET ("APPEND TEXT":Text$&VAL$(Checked))
2400 SUBEND